package com.future.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.future.domain.ChatMessage;
import com.future.domain.DTO.MessageDTO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;

@Mapper
public interface ChatMessageMapper extends BaseMapper<ChatMessage> {
    ChatMessage selectByRoomIdAndMessageId(@Param("roomId") long roomId, @Param("Id") long Id);

    List<ChatMessage> selectByRoomId(Long roomId);
   void batchInsert(
            @Param("messageId") Long messageId,
            @Param("chatRoomId") Long chatRoomId,
            @Param("userIds") List<Long> userIds);
    Integer countMessagesAfterCursor(
            @Param("roomId") Long roomId,
            @Param("lastMessageId") Long lastMessageId
    );
    MessageDTO MessageDTO(@Param("lastMessageId")Long lastMessageId);
    List<MessageDTO> queryMessagesByCursor(@Param("roomId")Long roomId,
                                           @Param("lastMessageId")Long lastMessageId,
                                           @Param("pageSize")Integer pageSize);
    void updateUnread(@Param("userId")Long userId,
                      @Param("roomId")Long roomId);
    Long selectRoomIdBymessageId(Long messageId);
    @MapKey("chat_room_id")
    Map<Long, Integer> countUnreadBatch(
            @Param("userId") Long userId,
            @Param("roomIds") List<Long> roomIds
    );
    void deleteMessage(Long mesageId);
    Integer countUnreadOne(@Param("userId")Long userId,
                           @Param("chatRoomId")Long chatRoomId);
    List<Long> roomList(@Param("userId")Long userId);
}
